<template lang="jade">
h-loader-full(url='loader')
  .box
    m-title(icon='add',name='修改公司资料')
    table.single
      mf-row(name='用户名：'): input(type='text',v-model='list.username')

      mf-row(name='修改密码：'): input(type='checkbox',v-model='changepwd')

      mf-row( v-if="changepwd", name='密码：'): input( type='password',v-model='password', @click="changepwd")

      mf-row(name='公司名称：'): input(type='text',v-model='list.cname')
      mf-row(name='公司地址：'): input(type='text',v-model='list.address')
      mf-row(name='公司邮箱：'): input(type='text',v-model='list.email')
      mf-row(name='联系人姓名：'): input(type='text',v-model='list.contact_name')
      mf-row(name='联系人电话：'): input(type='text',v-model='list.contact_mobile')
      mf-row(name='公司简介：'): textarea(style='width:500px; height:200px;',v-model='list.intro')
      mf-row(name='营业执照：'): mf-upload(uploadid='img', amount='1',  project='xiongan', category='license', rule='company', @upload_data='text', :data='list.license')
      mf-row(name='公司LOGO：'): mf-upload(uploadid='img1', amount='1',  project='xiongan',category='logo', rule='company', @upload_data='text1', :data='list.logo')
      mf-row(name='')
        button(@click='change') 确认修改
</template>
----------------------------------------------------------------------------------------
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
      loader:{ 
        detail:'get_company/datail/' + this.$query.get('id'),
        scope:'company/scope'
         },
      scope:[],
      detail:{},
      list:{
        certificate:[],
        license:[],
        logo:[],
        contract:[],
        id: this.$query.get('id')
      },
      password:'',
      changepwd:false,
	 }
  },
  mounted () {
    
  },
	methods: {
      loadAfter(res){
        this.detail = res.detail[0][0]
        this.list = this.detail
        if(this.list.license){
          this.list.license = this.list.license.split("|")
        }else{
          this.list.license = []
        }
        if(this.list.logo){
          this.list.logo = this.list.logo.split("|")
        }else{
          this.list.logo = []
        }
      },
      text(data){
        this.list.license = data
      },
      text1(data){
        this.list.logo = data
      },
      change(){

        if(this.changepwd){
          this.list.password = this.password;
        }else{
          delete this.list.password;
        }

        for(var key in this.list){
          var arr = ['ishot', 'binduser', "bindworker"];
          if(arr.indexOf(key) == -1){
            if(this.list[key] == ''){
              console.log(key);
              this.$msg.error('需要添加所有信息');
              return false;
            }
          }
        }



        this.$ajax.put('company/change',this.list,(res)=>{
          this.$msg.success('修改成功')
        },(res)=>{
          this.$msg.error('修改失败')
        })
      },
	  }
  }
</script>
----------------------------------------------------------------------------------------
<style lang="less" scoped>
@import "../../../plugin/style/mixin";

</style>